From 8a2061f581d3dcb3928ccd5aeac77f6127c52cf4 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 14 Apr 2016 22:52:59 -0400 Subject: [PATCH] inspector: Don't lie with statistics If we don't have statistics, despite GOBJECT_DEBUG being set, explain how to fix this. --- gtk/inspector/statistics.c | 11 +++++++++++ gtk/inspector/statistics.ui | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gtk/inspector/statistics.c b/gtk/inspector/statistics.c index fe33d18f03..42b315c49d 100644 --- a/gtk/inspector/statistics.c +++ b/gtk/inspector/statistics.c @@ -26,6 +26,7 @@ #include "gtkcellrenderertext.h" #include "gtkcelllayout.h" #include "gtksearchbar.h" +#include "gtklabel.h" enum { @@ -36,6 +37,7 @@ enum struct _GtkInspectorStatisticsPrivate { GtkWidget *stack; + GtkWidget *excuse; GtkTreeModel *model; GtkTreeView *view; GtkWidget *button; @@ -168,6 +170,12 @@ toggle_record (GtkToggleButton *button, static gboolean has_instance_counts (void) +{ + return g_type_get_instance_count (GTK_TYPE_LABEL) > 0; +} + +static gboolean +instance_counts_enabled (void) { const gchar *string; guint flags = 0; @@ -365,6 +373,8 @@ constructed (GObject *object) update_type_counts (sl); else { + if (instance_counts_enabled ()) + gtk_label_set_text (GTK_LABEL (sl->priv->excuse), _("GLib must be configured with --enable-debug")); gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->stack), "excuse"); gtk_widget_set_sensitive (sl->priv->button, FALSE); } @@ -452,6 +462,7 @@ gtk_inspector_statistics_class_init (GtkInspectorStatisticsClass *klass) gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, renderer_cumulative2); gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, search_entry); gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, search_bar); + gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, excuse); } diff --git a/gtk/inspector/statistics.ui b/gtk/inspector/statistics.ui index 82672db2d1..b1ceefce4e 100644 --- a/gtk/inspector/statistics.ui +++ b/gtk/inspector/statistics.ui @@ -159,7 +159,7 @@ center center - + True True Enable statistics with GOBJECT_DEBUG=instance-count -- 2.30.2